//
//  GGRootController.m
//  DDLock
//
//  Created by ios on 2017/12/25.
//  Copyright © 2017年 saiyi. All rights reserved.
//

#import "GGRootController.h"

@interface GGRootController ()
{
    BOOL _isAvailable;
}

@end

@implementation GGRootController

- (void)viewDidLoad {
    [super viewDidLoad];

    _isAvailable = YES;
    
    self.view.backgroundColor = kCommonBackgroundColor;
    
    [self setDidLoad];
    [self setRequest];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self setWillAppear];
    
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self setDidAppear];
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self setWillDisappear];
    
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [self setDidDisappear];
    
}

- (void)setDidLoad{

    _isAvailable = NO;
    
    UINavigationBar *bar = self.navigationController.navigationBar;
    bar.barTintColor = kCommonBlueColor;
    [bar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [bar setShadowImage:nil];
    [bar setTitleTextAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:18.0f], NSForegroundColorAttributeName : [UIColor whiteColor]}];
    
};
- (void)setWillAppear{
    
    if (!_isAvailable) return;
    UINavigationBar *bar = self.navigationController.navigationBar;
    [bar setBackgroundImage:[UIImage share] forBarMetrics:UIBarMetricsDefault];
    [bar setShadowImage:[UIImage share]];
    [bar setTitleTextAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:18.0f],NSForegroundColorAttributeName : [UIColor whiteColor]}];
    
}
- (void)setDidAppear{}
- (void)setWillDisappear{
    
    UINavigationBar *bar = self.navigationController.navigationBar;
    bar.barTintColor = kCommonBlueColor;
    [bar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [bar setShadowImage:nil];
    [bar setTitleTextAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:18.0f], NSForegroundColorAttributeName : [UIColor whiteColor]}];
    
}
- (void)setDidDisappear{}
- (void)setRequest{}

- (void)setAddTableView:(UITableViewStyle)style frame:(CGRect)frame target:(id)target {
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:frame style:style];
    self.tableView = tableView;
    tableView.delegate = target;
    tableView.dataSource = target;
    [self.view addSubview:tableView];
   
}

@end
